local duolamengxiang = fk.CreateSkill {
  name = "duolamengxiang",
  tags = { Skill.Wake },
}

Fk:loadTranslationTable{
  ["duolamengxiang"] = "哆啦梦想",
  [":duolamengxiang"] = "觉醒技，准备阶段，如果你的体力值小于体力值上限的一半，获得X点护甲（X=你的生命上限）并令所有梦之队势力玩家获得技能【覆写】",
}

duolamengxiang:addEffect(fk.EventPhaseStart, {
  anim_type = "support",
  can_trigger = function(self, event, target, player, data)
    return target == player and player:hasSkill(duolamengxiang.name) and player.phase == Player.Start and
      player:usedSkillTimes(duolamengxiang.name, Player.HistoryGame) == 0
  end,
  can_wake = function(self, event, target, player, data)
    local max = math.floor(player.maxHp/2)
    return player.hp < max
  end,
  on_use = function(self, event, target, player, data)
    local room = player.room
    for _, p in ipairs(room:getAlivePlayers()) do
      -- 为每个存活玩家添加 "n_fenliang" 技能
      -- 第三个参数 nil 表示不指定技能的额外参数，第四个参数 false 表示不是临时添加技能
      if p.kingdom == "dream" then
        -- 指示目标玩家指向额外目标
        room:handleAddLoseSkills(p, "haiwangfuxie")
     end
    end
    local armor = math.floor(player.maxHp)
    room:changeShield(player,armor)
  end,
})

return duolamengxiang
